package com.huilang.stream.demo1;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 收集
 */
public class StreamDemo3 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        Collections.addAll(list, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        List<Integer> list1 = list.stream().filter(integer -> integer % 2 == 0)
                .collect(Collectors.toList());
        list1.stream().forEach(integer -> System.out.println(integer));

        Set<Integer> list2 = list.stream().filter(integer -> integer % 2 == 0).collect(Collectors.toSet());

        System.out.println("============");
        Map<String, Integer> map = list.stream().collect(Collectors.toMap(integer -> integer + "a", integer -> integer));

        map.values().stream().forEach(integer -> System.out.println(integer));
        Collection<Integer> values = map.values();

        System.out.println(values);

    }
}
